package com.junye.collectiondemo.Utils;

import android.app.Activity;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by junye on 2016/6/28.
 */
public class ActiviyCollector {
    public static List<Activity> activities = new ArrayList<Activity>();
    private static final String TAG = "ActiviyCollector";

    public static void addActivity(Activity activity) {
        activities.add(activity);
        Log.e(TAG, "addActivity: " );
    }

    public static void removeActivity(Activity activity) {
        activities.remove(activity);
        Log.e(TAG, "removeActivity: " );
    }

    public static void finishAll() {
        Log.e(TAG, "finishAll: ");
        try {
            for (Activity activity : activities) {
                if (activity != null) {
                    activity.finish();
                }
            }
        }catch (Exception  e){

        }finally {
            System.exit(0);
        }

    }
}
